//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    isShow:false,
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  onLoad: function () {

    wx.getUserInfo({
      success: res => {
        // 可以将 res 发送给后台解码出 unionId
        app.globalData.userInfo = res.userInfo
        wx.redirectTo({
          url: '/pages/login/index',
        })
      },
      fail:res => {
        this.setData({isShow:true})
      },
    })

  },
  getUserInfo: function (e) {
    app.globalData.userInfo = e.detail.userInfo
    wx.redirectTo({
      url: '/pages/login/index',
    })
  }
})